package me.ydq.core;

import me.ydq.convert.ColumnConvert;
import me.ydq.core.table.*;
import me.ydq.dialect.Dialect;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

import java.util.function.Consumer;

/**
 * Table 封装操作类，不支持复用，每次查询需要重新创建
 */
public sealed interface Table<T> extends
        TablePage<T>,
        TableTop<T>,
        TableFirst<T>,
        TableUnique<T>,
        TableUpdate<T>,
        TableCount,
        TableDelete<T>,
        TableSort<T>,
        TableManual<T>,
        TableExtra<T>
        permits JdbcTable {

    static <T> Table<T> newInstance(NamedParameterJdbcTemplate jdbcTemplate,
                                    Dialect dialect,
                                    Class<T> cls,
                                    String table,
                                    ColumnConvert columnConvert,
                                    RowMapper<T> rowMapper) {
        return new JdbcTable<>(jdbcTemplate, dialect, cls, table, columnConvert, rowMapper);
    }


    Table<T> where(Consumer<SqlSpec<T>> builder);

}
